//
// Created by klen on 23-11-27.
//
#include <memory>  // for allocator, __shared_ptr_access, shared_ptr
#include <string>  // for string, basic_string
#include <vector>  // for vector

#include "ftxui/component/captured_mouse.hpp"  // for ftxui
#include "ftxui/component/component.hpp"  // for Radiobox, Horizontal, Menu, Renderer, Tab
#include "ftxui/component/component_base.hpp"      // for ComponentBase
#include "ftxui/component/screen_interactive.hpp"  // for ScreenInteractive
#include "ftxui/dom/elements.hpp"  // for Element, separator, hbox, operator|, border


int main() {
    using namespace ftxui;

    // 点击次数
    int count = 0;

    // 创建一个button, 点击时 count + 1
    auto button = Button("增加", [&]{
       count++;
    });

    auto dom = Renderer(button, [&]{
        return vbox({
            hbox({
                text("count: "),
                text(std::to_string(count))
            }),
            separator(),
            button->Render(),
        });
    });


    // 创建一个全屏交互屏幕
    auto screen = ScreenInteractive::Fullscreen();

    // 将页面输出到屏幕上
    screen.Loop(dom);
}